package com.worldvision.main.member;

import java.util.HashMap;
import java.util.Map;

import junit.framework.Assert.*;

import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.support.ui.Select;
import org.testng.Assert;

import com.worldvision.main.page.abstractPageObject;
import com.worldvision.main.util.UTIL;

public class MyProfilePage extends abstractLoginPage
{
	HashMap locator = new HashMap<String,String>()
			{
		{
			
		put("welcomeMsg","strong");
		put("lblMobileNumber","//td[3]/table/tbody/tr[3]/td");
		}
	};

	public MyProfilePage(WebDriver driver)
	{
		this.driver = driver;
	}
	public void checkWelcomeText(String username) {
		// TODO Auto-generated method stub
		Assert.assertTrue(driver.findElement(By.cssSelector("strong")).isDisplayed());
		Assert.assertTrue(driver.findElement(By.cssSelector("strong")).getText().contains(username));
		
	}
	public void logout() {
		// TODO Auto-generated method stub
		//driver.findElement(By.linkText("Logout")).click();
		driver.navigate().to("http://www.worldvision.in/logout");
	}
	public void checkMobileNumber(String mobileNumber) {
		// TODO Auto-generated method stub
		Assert.assertTrue(driver.findElement(By.xpath(locator.get("lblMobileNumber").toString())).getText().contains(mobileNumber));
		Assert.assertTrue(UTIL.checkInPage(driver,mobileNumber));
	}
	public void viewProfile() {
		// TODO Auto-generated method stub
		driver.findElement(By.linkText("Profile")).click();
		Assert.assertTrue(UTIL.checkInPage(driver,"My Profile"));
	}
	public void checkPartnerId(String partnerId) {
		// TODO Auto-generated method stub
		Assert.assertTrue(UTIL.checkInPage(driver,partnerId));
	}
	public void checkNameAndAddress(String text) {
		// TODO Auto-generated method stub
		Assert.assertTrue(UTIL.checkInPage(driver,text));
	}
	public void editProfile(Map<String,String> data)
	{
		String value;
		//driver.findElement(By.xpath("//a[contains(text(),'Edit Profile')]")).click();
		driver.findElement(By.xpath("//a[contains(text(),'Edit Profile')]")).sendKeys(Keys.ENTER);
		
		UTIL.fillFormData(driver,data);
		driver.findElement(By.xpath("//input[@name='Submit'][1]")).sendKeys(Keys.ENTER);
		
	}
	
	
}
